package com.xinyi.reactivemvvmkt.base.holder

import android.view.View
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView

/**
 * @author 杨耿雷
 * @date 2024/9/25 15:29
 * @description RecyclerView.ViewHolder的ViewBinding基类
 */
abstract class BaseViewBindingViewHolder<VDB : ViewDataBinding>(itemView: View) : RecyclerView.ViewHolder(itemView) {

    private lateinit var _binding: VDB

    /**
     * 获取ViewBinding对象
     */
    val binding: VDB get() = _binding

    private fun binding() {
        _binding = DataBindingUtil.bind(itemView)!!
    }

    init {
        binding()
    }
}